package leetcode每日一题;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

/**
 * 1. 问题描述
 *
 * 2. 算法分析
 *
 * 3. 代码实现
 */
@SuppressWarnings("all")
public class 按要求补齐数组 {

    private static HashSet<Integer> set = new HashSet<>();
    private static List<Integer> list = new ArrayList<>();

    public static void main(String[] args) {
        int[] a = {1,5,10};
        list.add(1); list.add(5); list.add(10);
        dfs(list,2);
        //dfs(list,4);
        for (Integer integer : set) {
            System.out.print(integer+" ");
        }
    }

    public static int minPatches(int[] nums, int n) {
        /*int ans = 0;
        for(int num : nums) {list.add(num);} // 初始化list
        dfs(0); // 初始化set
        for(int i = 1; i <= n; i++) {
            if(set.contains(i)) {
                continue;
            }
            set.add(i);
            list.add(i);
            dfs(i);
            ans++;
            boolean isOk = true;
            for(int k = 1; k <= n; k++) {
                if(!set.contains(k)) {
                    isOk = false;
                    break;
                }
            }
            if(isOk) {
                return ans;
            }
        }
        return -1;*/
        return -1;
    }

    public static void dfs(List<Integer>list,int num) {
        if(num != 0) {
            set.add(num);
            list.add(num);
        }
        int[] temp = new int[list.size()];
        for (int i = 0; i < list.size(); i++) {
            temp[i] = list.get(i);
            System.out.print(list.get(i)+" ");
        }
        System.out.println();
        for (int i = 1; i <= list.size(); i++) {
            // 求出list中i个元素的组合全体 此时可以使用dfs
        }
    }

}
